<template>
  <div class="contanier">
    <h1>网校组件</h1>
    <p>id路由参数: {{ id }}</p>
    <router-link :to="{ name: 'dcone' }">大触直播</router-link>
    <router-link :to="{ name: 'dctwo' }">大触专访</router-link>
    <router-link :to="{ name: 'dcthree' }">大触周边</router-link>
    <router-view></router-view>
    <p>getters: {{ $store.getters.infoTip }}</p>
    <button @click="getCount">获取store count</button>
    <button @click="setCount">设置store count</button>
    <button @click="getUsers(true)">获取stort users性别为true</button>
    <button @click="getUsers(false)">获取stort users性别为false</button>
  </div>
</template>

<script>
// import getUsers from "@utils/getUsers.js";
export default {
  name: "CourseView",
  data() {
    return {
      id: "",
    };
  },
  async created() {
    // this.$route: 各个组件都可以通过它，获取当前浏览器的路由信息。
    // console.log("------", this.$route);
    this.id = this.$route.query.id;
    this.id = this.$route.params.idss;
    // const data = await getUsers();
    // this.$store.commit("xxx", data);
  },
  methods: {
    getCount() {
      const count = this.$store.state.count;
      console.log("---", count);
      this.$store.commit("setCount", 200);
      console.log("===", this.$store.getters.infoTip);
    },
    setCount() {
      this.$store.commit("setCount", this.$store.state.count + 1);
    },
    getUsers(sex) {
      if (sex) console.log(this.$store.getters.allTrueSex);
      else console.log(this.$store.getters.allFalseSex);
    },
  },
};
</script>

<style lang="scss" scoped></style>
